<template>
  <div id="Account">
    <Filters
      block
      :form="searchForm"
      :filterData="filterData"
      @confirm="changePage(1)"
    />
    <div class="container">
      <div class="tree-box">
        <div class="left-tree">
          <a-input-search style="margin-bottom: 8px" placeholder="请输入部门名称/编码" @change="onChange" />
          <a-tree
            :expanded-keys="expandedKeys"
            :auto-expand-parent="autoExpandParent"
            :tree-data="treeData"
            @expand="onExpand"
            :replaceFields="replaceFields"
            @select="selectTree"
          >
          </a-tree>
          <div style="margin-top:20px">
            <a-pagination v-model="current" size="small" :total="treeTotal" @change="changeTreePage"/>
          </div>
        </div>
        <div class="right-table">
          <div>
            <a-button type="primary" icon='cloud-upload' @click="exportList" style="margin-right: 10px;">导出</a-button>
            <a-dropdown>
              <a-menu slot="overlay" @click="handleMenuClick">
                <a-menu-item key="1">角色配置</a-menu-item>
                <a-menu-item key="2">添加负责项目</a-menu-item>
                <a-menu-item key="3">添加请购部门</a-menu-item>
              </a-menu>
              <a-button type="primary"> 批量操作 <a-icon type="down" /> </a-button>
            </a-dropdown>

          </div>
          <DataTable
            rowKey="id"
            :tableData="Data"
            :tableColumn="tableColumn"
            :pageConfig="pageConfig"
            :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
            @refresh="getList"
          />
        </div>
      </div>
    </div>
    <CommonDialog :rows="rows" :form="form" :title="dialogType === 'add' ? '添加账户' : '编辑账户'" :visible="formVisible" @hideDialog="hideFormVisible" @confirm="confirmHandle('user')" />
    <CommonDialog :rows="resetRows" :form="resetForm" title="重置密码" :visible="resetFormVisible" @hideDialog="hideFormVisible" @confirm="confirmHandle('password')" />

    <CommonDialog :rows="rowsRole" :form="formRole" title="批量配置角色" :visible="formRoleVisible" @hideDialog="hideFormRoleVisible" @confirm="confirmformRole"/>
    <CommonDialog :rows="rowsProject" :form="formProject" title="批量添加项目" :visible="formProjectVisible" @hideDialog="hideFormProjectVisible" @confirm="confirmformProject"/>

    <CommonDialog :rows="rowsDept" :labelCol="{span: 6}" :wrapperCol="{span: 18}" :form="formDept" title="批量添加请购部门" :visible="formDeptVisible" @hideDialog="hideFormDeptVisible" @confirm="confirmformDept"/>

  </div>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator';
import util from '@/util/util';
import rules from '@/util/rules';
import md5 from 'js-md5';
import { MEMBER_EXPORT } from '@/api/global';
import { Color } from '@antv/attr';

@Component
export default class Account extends Vue {
  searchForm: any = {
    searchValue: '',
    date: [],
    status: undefined
  };
  formDeptVisible:any = false
  formRoleVisible:any = false
  formProjectVisible:any = false
  current:any = 1
  treeTotal:any = 0
  currentPage:any = 1
  get filterData () {
    return {
      status: {
        label: '状态',
        type: 'select',
        template: {
          placeholder: '请选择状态',
          clearable: true,
          filterable: true,
          options: this.statusList
        }
      },
      date: {
        label: '时间',
        type: 'daterange',
        template: {
          clearable: true
        }
      },
      searchValue: {
        label: '用户名称/手机号码/用户编码',
        type: 'input',
        template: {
          placeholder: '请输入用户名称/手机号码/用户编码',
          clearable: true
        }
      }
    };
  }
  selectedRowKeys: any[] = []
  Data: any[] = [];
  tableColumn: any = {
    userCode: {
      label: '用户编码',
      minWidth: 120
    },
    account: {
      label: '账号名称',
      minWidth: 120
    },
    memberName: {
      label: '姓名',
      minWidth: 120
    },
    businessUnitName: {
      label: '所属部门',
      minWidth: 100
    },
    // higherBranch: {
    //   label: '上级部门',
    //   minWidth: 100
    // },
    memberPhone: {
      label: '手机号',
      minWidth: 100
    },
    createTime: {
      label: '创建时间',
      minWidth: 170
    },
    status: {
      label: '状态',
      type: 'switch',
      callback: this.handleUpdateStatus,
      minWidth: 170
    },
    action: {
        label: '操作',
        width: 260,
        template: [
            {
                tag: 'a',
                text: '编辑',
                callback: this.showEditDialog
            },
            {
                tag: 'a',
                text: '删除',
                callback: this.deleteAccount
            },
            {
                tag: 'a',
                text: '重置密码',
                callback: this.showResetDialog
            }
        ]
    }
  };
  pageConfig: any = {
    current: 1,
    total: 10,
    pageSize: 10,
    onChange: this.changePage
  };
  roleList: any[] = [];
  formVisible: boolean = false;
  dialogType: string = 'add';
  searchKey:string = ''
  form: any = {
    businessUnitId: undefined,
    email: '',
    memberPhone: '',
    memberName: '',
    account: '',
    password: '',
    roleId: undefined,
    projectIds: [],
    repassword: '',
    status: true,
    deptIds: []
  };
  formRole:any = {
    ids: ''
  }
  formProject:any = {
    ids: undefined
  }
  formDept:any = {
    ids: undefined
  }
  groupList: any = [] // 单位列表
  projectList: any = [] // 项目列表
  initProject:any = []
  deptIds:any = []
  get rowsRole () {
    return {
      ids: {
        label: '角色配置',
        el: 'select',
        placeholder: '请选择角色',
        options: this.roleList,
        rules: [{ required: true, message: '请选择角色', trigger: 'blur' }]
      }
    }
  }
  get rowsProject () {
    return {
      ids: {
        label: '选择项目',
        el: 'select',
        mode: 'multiple',
        placeholder: '请选择选择项目',
        options: this.projectList,
        popupScroll: this.popupScroll,
        rules: [{ required: true, message: '请选择选择项目', trigger: 'blur' }]
      }
    }
  }
  get rowsDept () {
    return {
      ids: {
        label: '选择请购部门',
        el: 'treeSelect2',
        mode: 'multiple',
        placeholder: '请选择请购部门',
        options: this.memberorgList,
        rules: [{ required: true, message: '请选择请购部门', trigger: 'blur' }],
        selectTreeData: this.selectTreeMemberOrg,
        search: this.searchTreeMemberOrg
      }
    }
  }
  get rows () {
    return {
      memberName: {
        label: '姓名',
        placeholder: '请输入姓名',
        rules: [{ required: true, message: '请输入姓名', trigger: 'blur' }]
      },
      businessUnitName: {
        label: '所属部门',
        placeholder: '请输入姓名',
        showDisabled: true
        // rules: [{ required: true, message: '请输入姓名', trigger: 'blur' }]
      },
      // businessUnitId: {
      //   label: '所属单位',
      //   el: 'treeSelect',
      //   placeholder: '请选择所属单位',
      //   options: this.companyList,
      //   showDisabled: true,
      //   rules: [{ required: true, message: '请选择所属单位', trigger: 'blur' }],
      //   search: this.searchCompany,
      //   selectTreeData: this.selectTreeData,
      //   replaceFields: {
      //     children: 'childs',
      //     title: 'name',
      //     key: 'id',
      //     value: 'name'
      //   }
      // },
      userCode: {
        label: '用户编码',
        placeholder: '请输入用户编码'
        // rules: [
        //   { required: true, message: '请输入用户编码', trigger: 'blur' }
        // ]
      },
      memberPhone: {
        label: '手机号码',
        placeholder: '请输入手机号码'
        // rules: [
        //   { validator: rules.checkPhone(), trigger: 'blur' },
        //   { required: false, message: '请输入手机号码', trigger: 'blur' }
        // ]
      },
      email: {
        label: '邮箱',
        placeholder: '请输入邮箱'
        // rules: [
        //   { validator: rules.email(), trigger: 'blur' },
        //   { required: true, message: '请输入邮箱', trigger: 'blur' }
        // ]
      },
      account: {
        label: '账号名称',
        placeholder: '请输入账号名称',
        showDisabled: this.dialogType !== 'add',
        rules: [{ required: true, message: '请输入账号名称', trigger: 'blur' }]
      },
      password: {
        label: '账户密码',
        placeholder: '请输入账户密码',
        show: this.dialogType === 'add',
        rules: [
          { validator: rules.checkLenInterval(6, 12), trigger: 'blur' },
          { min: 6, message: '密码至少6位数字', trigger: 'blur' },
          { required: true, message: '旧密码至少6位数字', trigger: 'blur' }
        ]
      },
      roleId: {
        label: '角色',
        el: 'select',
        placeholder: '请选择角色',
        options: this.roleList,
        rules: [{ required: true, message: '请选择角色', trigger: 'blur' }]
      },
      projectIds: {
        label: '负责项目',
        el: 'select',
        mode: 'multiple',
        placeholder: '请选择项目（可多选）',
        options: this.projectList,
        popupScroll: this.popupScroll,
        rules: [{ required: true, message: '请选择角色', trigger: 'blur' }],
        search: this.getPrijectWordKey,
        callback: this.handleChanges
      },
      deptIds: {
        label: '请购部门',
        el: 'treeSelect2',
        mode: 'multiple',
        placeholder: '请选择请购部门（可多选）',
        options: this.memberorgList,
        // rules: [{ required: true, message: '请选择请购部门', trigger: 'blur' }],
        selectTreeData: this.selectTreeMemberOrg,
        search: this.searchTreeMemberOrg
      },
      status: {
        label: '状态消息',
        el: 'radio',
        option: [
          {
            label: '启用',
            value: true
          },
          {
            label: '禁用',
            value: false
          }
        ],
        rules: [
          { required: true, message: '请选择状态', trigger: 'blur' }
        ]
      },
      remark: {
        el: 'textarea',
        label: '备注',
        placeholder: '请输入备注',
        showDisabled: this.dialogType !== 'add',
        rules: [{ required: false, message: '请输入备注', trigger: 'blur' }]
      }
    };
  }
  resetFormVisible: boolean = false;
  resetForm: any = {
    adminId: '',
    password: '',
    repassword: ''
  };
  btns: any = [
    // {
    //   label: '新增',
    //   icon: 'add',
    //   callback: this.addAccount
    // },
    // {
    //   label: '删除',
    //   callback: this.handleBatch
    // },
    {
      label: '导出',
      icon: 'export',
      callback: this.exportList
    }
  ]
  replaceFields: any = {
    children: 'childs',
    title: 'name',
    key: 'id'
  }
  get resetRows () {
    return {
      password: {
        label: '新密码',
        placeholder: '请输入新密码',
        rules: [
          { validator: rules.checkLenInterval(6, 12), trigger: 'blur' },
          { min: 6, message: '新密码至少6位数字', trigger: 'blur' },
          { required: true, message: '新密码至少6位数字', trigger: 'blur' }
        ]
      }
    };
  }
  statusList: any[] = [
    {
      label: '全部',
      value: ''
    },
    {
      label: '正常',
      value: 1
    },
    {
      label: '冻结',
      value: 0
    }
  ];
  expandedKeys: any[] = []
  searchValue: string = ''
  autoExpandParent: boolean = true
  treeData: any[] = []
  treeData2: any[] = []
  companyList:any[] = []
  companyId:any = ''
  companyKey:any = ''
  selectArr: any = []
  word: any = '' // 组织架构搜索
  departId: any = '' // 选择的组织id
  memberorgList:any = [] // 请购组织列表
  memberDeptList:any = [] // 请购部门列表
  init () {
    this.projectList = []
    this.getList()
    this.getOrgList()
    this.getOrgList2()
    this.getDownRole();
    // this.getGroupList()
    this.getProjectList()
    this.getMemberOrgList()
    this.getProjectList()
  }
  // 选择批量项
  handleMenuClick (val:any) {
    let key = val.key
    if (this.selectedRowKeys.length == 0) {
      return this.$message.error('请选择批量操作人员')
    }
    if (key == 1) {
      this.formRoleVisible = true
    } else if (key == 2) {
      this.formProjectVisible = true
    } else {
      this.formDeptVisible = true
    }
    console.log(val)
  }
  hideFormRoleVisible () {
    this.formRoleVisible = false
    this.formRole.ids = ''
  }
  hideFormProjectVisible () {
    this.formProjectVisible = false
    this.formProject.ids = undefined
    this.currentPage = 1
  }
  hideFormDeptVisible () {
    this.formDeptVisible = false
    this.formDept.ids = undefined
    this.deptIds = []
  }
  confirmformDept () {
    let data = {
      ids: this.deptIds.join(','),
      memberIds: this.selectedRowKeys,
      type: 'dept'
    }
    this.$api.memberBatchHandleFetch(data).then(res => {
      if (res.code == 0) {
        this.$message.success('操作成功');
        setTimeout(() => {
          this.hideFormDeptVisible()
          this.getList()
        }, 1000);
      }
    }).catch()
  }
  confirmformProject () {
    let data = {
      ids: this.formProject.ids.join(','),
      memberIds: this.selectedRowKeys,
      type: 'project'
    }
    this.$api.memberBatchHandleFetch(data).then(res => {
      if (res.code == 0) {
        this.$message.success('操作成功');
        setTimeout(() => {
          this.hideFormProjectVisible()
          this.getList()
        }, 1000);
      }
    }).catch()
  }
  confirmformRole () {
    let data = {
      ids: this.formRole.ids,
      memberIds: this.selectedRowKeys,
      type: 'role'
    }
    this.$api.memberBatchHandleFetch(data).then(res => {
      if (res.code == 0) {
        this.$message.success('操作成功');
        setTimeout(() => {
          this.hideFormRoleVisible()
          this.getList()
        }, 1000);
      }
    }).catch()
  }

  // 获取关键字
  getPrijectWordKey (val:any) {
    this.searchKey = val
    this.currentPage = 1
    this.projectList = []
    this.getProjectList()
  }
  handleChanges (val:any) {
    console.log(val, '----')
  }
  changeTreePage (val:any) {
    this.current = val
    this.getOrgList()
    console.log(val, 'val')
  }
  // 部门列表
  getOrgList () {
    let { word } = this
    let data = { word, page: this.current, size: 10 }
    this.$api.organizationListFetch(data).then((res: any) => {
      if (res.data) {
        this.treeData = res.data.records
        this.treeTotal = res.data.total
      } else {
        this.treeData = []
        this.treeTotal = 0
      }
    })
  }
  // 搜索单位
  searchCompany (val:any) {
    this.companyKey = val
    this.companyList = []
    this.page = 1
    this.getOrgList2()
  }
  selectTreeData (val:any) {
    var id = val.replace(/[^0-9]/ig, '')
    this.companyId = id
  }
  // 部门列表
  getOrgList2 () {
    let data = { word: this.companyKey, page: 1, size: 200 }
    this.$api.organizationListFetch(data).then((res: any) => {
      if (res.data) {
        res.data.records.forEach((item:any) => {
          this.companyList.push(Object.assign(item, {}));
        });
        console.log(this.companyList, '===')
      } else {
        this.companyList = []
      }
    })
  }
  // 滚动选择框时执行
  popupScroll (e:any) {
    const { scrollHeight, scrollTop, clientHeight } = e.target
      if (Math.floor(scrollHeight - scrollTop) === clientHeight) {
        this.currentPage++
        this.getProjectList()
      }
  }
  // 获取请购组织列表
  getMemberOrgList () {
    this.$api.memberOrgListFetch().then(res => {
      if (res.code == 0) {
        res.data.map((item:any) => {
          item.id = item.orgCode
          item.name = item.orgName
          item.title = item.orgCode + item.orgName
          item.disabled = true
        })
        this.getMemberDeptList(res.data)
        this.memberorgList = res.data
      }
    }).catch()
  }
  // 获取请购部门列表
  getMemberDeptList (list:any) {
    list.forEach((item:any) => {
      let data = {
        orgCode: item.orgCode,
        name: ''
      }
      this.$api.memberDeptListFetch(data).then(res => {
        if (res.code == 0) {
          res.data.map((kk:any) => {
            kk.id = kk.pkDept
            kk.name = kk.deptName
            kk.title = kk.pkDept + kk.deptName
          })
          item.childs = res.data
          // this.memberDeptList = res.data
        }
      }).catch()
    })
  }
  // 选择请购部门
  selectTreeMemberOrg (val:any) {
    let arr:any = []
    val.forEach((jj:any) => {
       this.memberorgList.forEach((item:any) => {
        item.childs.forEach((kk:any) => {
          if (kk.title == jj) {
            arr.push(kk.id)
          }
        })
      })
    })
    this.deptIds = arr
  }
  // 搜索
  searchTreeMemberOrg (val:any) {
    console.log(val)
    console.log(this.memberorgList)
  }

  // 通过选择的id查询下一级人员
  getFindsID (list:any, id:any) {
    for (let i = 0; i < list.length; i++) {
      let itemList = list[i]
      if (itemList.id == id) {
        this.$api.organizationNextChlidFetch({id: id}).then(res => {
          if (res.data.length > 0) {
            itemList.childs = res.data
          }
        }).catch()
      } else {
        if (itemList.childs && itemList.childs.length > 0) {
          this.getFindsID(itemList.childs, id)
        }
      }
    }
  }

  // 选择树
  selectTree (selectedKeys: any) {
    console.log('选择树', selectedKeys)
    this.getFindsID(this.treeData, selectedKeys[0])
    this.departId = selectedKeys[0]
    this.getList()
  }
  getSearchForm () {
    let searchForm = JSON.parse(JSON.stringify(this.searchForm));
    let { date } = searchForm;
    let { current, pageSize } = this.pageConfig
    let form = Object.assign(searchForm, {
      page: current,
      size: pageSize,
      startTime: (date && date[0]) || '',
      endTime: (date && date[1]) || '',
      businessUnitId: this.departId
    });

    console.log(form, '==')
    delete form.date;
    return form;
  }
  getList () {
    let data = this.getSearchForm()
    this.$api.memberListFetch(data).then((res: any) => {
      res.data.records.map((item:any) => {
        if (item.status == 1) {
          item.status = true
        } else {
          item.status = false
        }
      })
      this.Data = res.data.records;
      this.pageConfig.total = res.data.total;
      if (!this.Data.length && this.pageConfig.current > 1) {
        --this.pageConfig.current;
        this.getList();
      }
    });
  }
  // 角色列表
  getDownRole () {
    this.$api.memberDownRoleFetch().then((res: any) => {
      this.roleList = res.data.map((item: any) => ({
        label: item.roleName,
        value: item.roleId
      }));
      console.log(this.roleList);
    });
  }
  // 单位列表
  getGroupList () {
    this.$api.memberBusinessUnitListFetch().then((res: any) => {
      this.groupList = res.data.map((item: any) => ({
        label: item.name,
        value: item.id
      }));
    })
  }
  // 项目列表
  getProjectList () {
    let listArr:any = []
    this.$api.projectRoleProjectListFetch({page: this.currentPage, size: 20, searchValue: this.searchKey}).then((res: any) => {
      // this.projectList = this.projectList.concat(this.initProject)
      if (res.data.records.length > 0) {
        listArr = res.data.records.map((item: any) => ({
          label: item.ncProjectName,
          value: item.ncProjectId
        }));
        this.projectList = this.projectList.concat(listArr)
        // this.projectList = this.objUnique(this.projectList)
      }
       this.projectList = this.objUnique(this.projectList)

      console.log(this.projectList, 'this.projectList')
    }).catch((err:any) => {

    })
  }

  onExpand (expandedKeys: any[]) {
    this.expandedKeys = expandedKeys;
    this.autoExpandParent = false;
  }
  onChange (e: any) {
    const value = e.target.value;
    this.word = value
    this.getOrgList()
  }
  onSelectChange (selectedRowKeys: string[], row: any) {
    this.selectedRowKeys = selectedRowKeys
    this.selectArr = row

    console.log(this.selectedRowKeys, 'this.selectedRowKeys')
    console.log(row)
  }
  // 树的选择
  handleSelectTree () {}
  changePage (val: number) {
    this.pageConfig.current = val;
    this.getList();
  }
  // 点击新增账号
  addAccount () {
    this.showFormVisible()
    this.formVisible = true
  }
  showFormVisible () {
    this.form = {
      account: '',
      password: '',
      roleId: undefined,
      businessUnitId: undefined,
      memberName: '',
      memberPhone: '',
      email: '',
      projectIds: [],
      status: true
    };

    this.dialogType = 'add';
    this.formVisible = true;
  }
  showResetDialog (row: any) {
    this.resetForm = {
      adminId: row.id,
      password: ''
      // repassword: ''
    };
    this.resetFormVisible = true;
  }
  confirmHandle (type: string) {
    console.log('确认添加', this.form)
    let data = JSON.parse(JSON.stringify(this.form))
    this.form.projectIds = data.projectIds.join(',')
    // this.form.deptIds = this.deptIds.join(',')
    this.form.status = +data.status
    // this.form.businessUnitId = this.companyId
    if (type === 'user') {
      let data = { ...this.form };
      data.deptIds = this.deptIds.join(',')
      console.log(data, '====')
      if (this.dialogType === 'add') {
        data.password = md5(data.password);
        // data.repassword = md5(data.repassword);
      }
      console.log(data, 'datada111tadata')
      let apiFetch =
        this.dialogType === 'add'
          ? this.$api.memberAddFetch
          : this.$api.memberUpdateFetch;
      apiFetch(data)
        .then((res: any) => {
          this.$message.success(
            this.dialogType === 'add' ? '新增账号成功' : '编辑账号成功'
          );
          this.formVisible = false;
          this.getList();
        })
        .catch(() => {
          this.formVisible = false;
        });
    } else if (type === 'password') {
      let data = { ...this.resetForm };
      data.password = md5(data.password);
      this.$api
        .memberResetPwdFetch(data)
        .then((res: any) => {
          this.$message.success('重置成功');
          this.form.businessUnitId = undefined
          this.resetFormVisible = false;
          this.getList();
        })
        .catch(() => {
          this.resetFormVisible = false;
        });
    }
  }
  showEditDialog ({ id }: any) {
    let arr:any = []
    let arrId:any = []
    let initProject:any[] = []
    // this.getProjectList()
    this.$api.memberDetailFetch({ adminId: id }).then((res: any) => {
      // this.projectList = []
      res.data.projectIds = res.data.projectIds ? res.data.projectIds.split(',') : ''
      res.data.projectName = res.data.projectName ? res.data.projectName.split(',') : ''

      res.data.deptIds = res.data.deptIds ? res.data.deptIds.split(',') : []
      res.data.deptNames = res.data.deptNames ? res.data.deptNames.split(',') : []

      res.data.deptIds.forEach((jj:any) => {
        this.memberorgList.forEach((item:any) => {
          item.childs.forEach((kk:any) => {
            if (jj == kk.pkDept) {
              arr.push(kk.title)
              arrId.push(kk.pkDept)
            }
          })
        })
      })

      res.data.deptIds = arr
      this.deptIds = arrId
      console.log(this.memberorgList, 'this.memberorgListthis.memberorgListthis.memberorgListthis.memberorgList')
            console.log(res.data, 'res.data')
      if (res.data.projectName) {
        res.data.projectName.forEach((item:any, index:any) => {
          let objArr = {label: '', value: ''}
          objArr.label = item
          objArr.value = res.data.projectIds[index]
          initProject.unshift(objArr)
        });
        this.projectList = this.projectList.concat(initProject)
        this.projectList = this.objUnique(this.projectList)
      }


      if (res.data.status == 1) {
        res.data.status = true
      } else {
        res.data.status = false
      }
      this.form = res.data;
      delete this.form.projectName
      this.dialogType = 'edit';
      this.formVisible = true;
    });
  }
  // 对象去重
  objUnique (obj:any) {
      const res = new Map();
      return obj.filter((item:any) => !res.has(item.value) && res.set(item.value, 1))
  }
  hideFormVisible () {
    this.initProject = []
    // this.projectList = []
    this.formVisible = false;
    this.resetFormVisible = false;
  }
  searchHandle () {
    this.pageConfig.current = 1;
    this.getList();
  }
  async handleUpdateStatus (row: any, index: number) {
    console.log(row)
    let status = 0
    let { id } = row;
    if (row.status) {
      status = 1
    } else {
      status = 0
    }
    this.$api
      .memberStatusFetch({ adminId: id, status: status })
      .then((res: any) => {
        this.$message.success(`${status ? '启用' : '禁用'}成功`);
        this.getList();
      });
  }
  // 删除账号
  deleteAccount (row: any) {
    let { id } = row;
    this.$confirm({
      title: '提示',
      content: '确定删除该账号？',
      onOk: () => {
        this.$api.memberDeleteFetch({ adminId: id }).then((res: any) => {
          this.$message.success('删除成功')
          this.getList()
        });
      }
    })
  }
  // 批量删除
  handleBatch () {
    if (!this.selectArr.length) return this.$message.error('请选择数据')
    let adminId = this.selectArr.map((item: any) => item.id).join(',')
    let data = { adminId }
    this.$confirm({
      title: '提示',
      content: '确定删除？',
      onOk: () => {
        this.$api.memberDeleteFetch(data).then((res: any) => {
            this.$message.success('删除成功')
            this.selectedRowKeys = []
            this.selectArr = []
            this.getList()
        });
      }
    })
  }
  exportList () {
    let form = this.getSearchForm();
    util.exportExcelFun(form, MEMBER_EXPORT);
  }
}
</script>

<style lang="scss" scoped>
#Account{
  .tree-box{
    width: 100%;
    display: flex;
    .left-tree{
      width: 20%;
      margin-right: 40px;
      flex-shrink: 0;
    }
    .right-table{
      flex: 1;
    }
  }
}
</style>
